<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
		<title>Registration Page</title>
		<script src="validate.js" type="text/javascript"> </script>
    </head>

<body onload="hide()">
				
	<h2>Create an Account</h2>
		<p>If you already have a an Account, you can   
			<a href="index.jsp">login here</a>
		</p>
	<h3>Required information for an account</h3>

	<form action="Registration" method="post" onsubmit="return formValidation(this);">
		<table>
			<tr><td>User Name:</td>
				<td><input type="text" name="username" size="15"/></td>
			</tr>
			<tr><td>Password:</td>
				<td><input type="password" name="password" size="15"/></td>
			</tr>
			<tr><td>Re-enter password:</td>
				<td><input type="password" name="password2" size="15"/></td>
			</tr>
			<tr><td>First Name:</td>
				<td><input type="text" name="firstName" size="15"/></td>
			</tr>
			<tr><td>Last Name:</td>
				<td><input type="text" name="lastName" size="15"/></td>
			</tr>
			<tr><td>Phone Number:</td>
				<td><input type="text" name="number" size="15"/></td>
			</tr>
			<tr><td>Administrator account?</td>
				<td><input type="radio" name="choice" value="yes" onclick="show()"/>Yes
					<input type="radio" name="choice" value="no" CHECKED onclick="hide()"/>No</td>
			</tr>
			<tr id="adminCode">
				<td id=>Please enter the administrator code:</td>
				<td><input type="password" name="code" value="" size="15"/></td>
			</tr>
		</table>
		<input class="reg" type="submit" value="Create my account"></input>
	</form>
	
	<%
		String usernameExist = (String)request.getSession().getAttribute("usernameExist");
		if (usernameExist != null) { %>
			<script type="text/javascript"> 
				alert("Registration Failed!\n"  +
					  "Username already exist!\n" +
					  "Please choose another Username"); 
			</script>

	<% 	request.getSession().removeAttribute("usernameExist");
		} else {
			String wrongCode = (String)request.getSession().getAttribute("wrongCode");
			if (wrongCode != null) { %>
				<script type="text/javascript"> 
					alert("Registration Failed!\n"  +
						  "wrong administrator code!");
				</script>
    <%	request.getSession().removeAttribute("wrongCode");
			}
		} %>
</body>
</html>
